package com.j2eefast.flowable.bpm.service;


import com.j2eefast.flowable.bpm.entity.bpmCrmCarinfoEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmCarinfoMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 车辆信息Service接口
 * @author: yhli
 * @date 2020-06-30 14:27
 */
@Service
public class bpmCrmCarinfoService extends ServiceImpl<bpmCrmCarinfoMapper,bpmCrmCarinfoEntity> {

	@Resource
	private bpmCrmCarinfoMapper bpmCrmCarinfoMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmCarinfoEntity> queryWrapper = new QueryWrapper<bpmCrmCarinfoEntity>();
                             String salesOrderNumber = (String) params.get("salesOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(salesOrderNumber), "sales_order_number", salesOrderNumber);
          String contractPrice = (String) params.get("contractPrice");
         queryWrapper.eq(ToolUtil.isNotEmpty(contractPrice), "contract_price", contractPrice);
          String orderIsTax = (String) params.get("orderIsTax");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsTax), "order_is_tax", orderIsTax);
          String orderIsTransport = (String) params.get("orderIsTransport");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsTransport), "order_is_transport", orderIsTransport);
          String orderIsGuarantee = (String) params.get("orderIsGuarantee");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsGuarantee), "order_is_guarantee", orderIsGuarantee);
             String carVin = (String) params.get("carVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(carVin), "car_vin", carVin);
          String carVehicle = (String) params.get("carVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(carVehicle), "car_vehicle", carVehicle);
          String carMileage = (String) params.get("carMileage");
         queryWrapper.eq(ToolUtil.isNotEmpty(carMileage), "car_mileage", carMileage);
          String carTranmission = (String) params.get("carTranmission");
         queryWrapper.eq(ToolUtil.isNotEmpty(carTranmission), "car_tranmission", carTranmission);
          String carDrivertrain = (String) params.get("carDrivertrain");
         queryWrapper.eq(ToolUtil.isNotEmpty(carDrivertrain), "car_drivertrain", carDrivertrain);
          String carStatus = (String) params.get("carStatus");
         queryWrapper.eq(ToolUtil.isNotEmpty(carStatus), "car_status", carStatus);
          String channelHighestPrice = (String) params.get("channelHighestPrice");
         queryWrapper.eq(ToolUtil.isNotEmpty(channelHighestPrice), "channel_highest_price", channelHighestPrice);
        		Page<bpmCrmCarinfoEntity> page = bpmCrmCarinfoMapper.selectPage(new Query<bpmCrmCarinfoEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmCarinfoEntity bpmCrmCarinfoEntity) {
		Page<bpmCrmCarinfoEntity> page = bpmCrmCarinfoMapper.findPage(new Query<bpmCrmCarinfoEntity>(params).getPage(), bpmCrmCarinfoEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmCarinfoByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmCarinfoById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmCarinfo(bpmCrmCarinfoEntity bpmCrmCarinfo){
        return save(bpmCrmCarinfo);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmCarinfoById(bpmCrmCarinfoEntity bpmCrmCarinfo) {
		return updateById(bpmCrmCarinfo);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmCarinfoEntity getbpmCrmCarinfoById(String id){
		return getById(id);
	}
}
